//! \brief Node should NOT be used as leaf objects on the scene.

#ifndef GRAPHICS__NODE_H_
#define GRAPHICS__NODE_H_

#include "Spatial.h"
#include "Renderer.h"

using namespace poly;

namespace graphics
{

class Renderer;

class Node : public Spatial
{
public:
	Node();
	/**
	 * @return Size of child vector.
	 */
	int getSize();
	/**
	 * @return Number of occupied Spatial spaces in the child vector.
	 */
	int getOccupied();
	/**
	 * Attaches a Spatial child to the first NULL space in the vector.
	 * @param New Spatial child to be added.
	 * @return Index of the new child.
	 */
	int AttachChild(Spatial*);
	/**
	 * Detaches the first Spatial child found to contain the same values and returns the index .
	 * @param Spatial child to be compared.
	 * @return Index of the found child.
	 */
	int DetachChild(Spatial*);
	/**
	 * Detaches child.
	 * @param Index.
	 * @return Detached child.
	 */
	Spatial* DetachChildAt(int);
	/**
	 * Retrieves the child with no modifications
	 * @param Index. (Should be inside vector size)
	 * @return Spatial child at the index.
	 */
	Spatial* GetChild(int);
	/**
	 * Adds the child to the index.
	 * @param Index.
	 * @param Spatial child.
	 * @return Old Spatial child if there was one at the index.
	 */
	Spatial* SetChild(int, Spatial*);
	
	/**
	 * Internal call, calls children to draw.
	 */
	virtual void Draw(Renderer&);

	/**
	 * Internal call, updates world data of itself and its children.
	 */
	virtual void UpdateWorldData(float dt);
private:
	/**
	 * Child vector.
	 */
	std::vector<Spatial*> m_child;
	/**
	 * Number of occupied Spatial spaces in the child vector.
	 */
	int m_used;
};

}/* namespace graphics */
#endif /*GRAPHICS__NODE_H_*/